#include "Avalon/WebServices/HttpMethod.hpp"

using namespace Avalon;
using namespace Avalon::WebServices;
using namespace std;

HttpMethodDefinition::Type HttpMethodDefinition::ParseString(
    const string& source) {
  if(source == "HEAD") {
    return HEAD;
  } else if(source == "GET") {
    return GET;
  } else if(source == "POST") {
    return POST;
  } else if(source == "PUT") {
    return PUT;
  } else if(source == "DELETE") {
    return DELETE;
  } else if(source == "TRACE") {
    return TRACE;
  } else if(source == "OPTIONS") {
    return OPTIONS;
  } else if(source == "CONNECT") {
    return CONNECT;
  } else if(source == "PATCH") {
    return PATCH;
  } else {
    return static_cast<Type>(-1);
  }
}

const string& HttpMethodDefinition::ToString() const {
  if(static_cast<const HttpMethod&>(*this) == HEAD) {
    static string value = "HEAD";
    return value;
  } else if(static_cast<const HttpMethod&>(*this) == GET) {
    static string value = "GET";
    return value;
  } else if(static_cast<const HttpMethod&>(*this) == POST) {
    static string value = "POST";
    return value;
  } else if(static_cast<const HttpMethod&>(*this) == PUT) {
    static string value = "PUT";
    return value;
  } else if(static_cast<const HttpMethod&>(*this) == DELETE) {
    static string value = "DELETE";
    return value;
  } else if(static_cast<const HttpMethod&>(*this) == TRACE) {
    static string value = "TRACE";
    return value;
  } else if(static_cast<const HttpMethod&>(*this) == OPTIONS) {
    static string value = "OPTIONS";
    return value;
  } else if(static_cast<const HttpMethod&>(*this) == CONNECT) {
    static string value = "CONNECT";
    return value;
  } else if(static_cast<const HttpMethod&>(*this) == PATCH) {
    static string value = "PATCH";
    return value;
  } else {
    static string value = "UNKNOWN";
    return value;
  }
}
